<?php

namespace App\Providers;

use App\Models\ShopPermission;
use Laravel\Passport\Passport;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();


        Passport::routes();

        // 此处是shop_clerk的权限处理 餐馆工作人员的权限  not yet
     /*   $permissions = ShopPermission::with('roles')->get();
        foreach ($permissions as $permission) {
            Gate::define($permission->name, function($user) use($permission) {
                return $user->hasPermission($permission);
            });
        }*/
//        Passport::tokensExpireIn(now()->addDays(15));
//        Passport::refreshTokensExpireIn(now()->addDays(30));
    }
}
